import request from '@/utils/request';
// 用户管理
export function listUsers(url, method, data) {
  let datas = {
    url: '/api/user' + url,
    method: method
  };
  if (method == 'get') {
    datas.params = data;
  } else {
    datas.data = data;
  }
  return request(datas);
}

// 组织机构 list
export function listOrganizations(data) {
  return request({url: '/api/organization', method: 'get', params: data});
}
// 组织机构 tree
export function organizationsTree(data) {
  return request({url: '/api/organization/tree', method: 'get', data: data});
}
// 组织机构新增
export function createOrganization(data) {
  return request({url: '/api/organization/insertOrganization', method: 'post', data: data});
}
// 组织机构修改
export function updateOrganization(data) {
  return request({url: `/api/organization/updateOrganization`, method: 'put', data: data});
}
// 组织机构删除
export function deleteOrganizationById(url) {
  return request({url: `/api/organization/updateOrganization/${url}`, method: 'PATCH'});
}

// 角色列表
export function listAllRoles(data) {
  return request({url: '/api/roles/selectRoles', method: 'get', data: data});
}
// 统计类
export function operations(url, method, data) {
  let datas = {
    url: '/api/operation' + url,
    method: method
  };
  if (method == 'get') {
    datas.params = data;
  } else {
    datas.data = data;
  }
  return request(datas);
}
export function alarms(url, method, data) {
  let datas = {
    url: '/api/alarm' + url,
    method: method
  };
  if (method == 'get') {
    datas.params = data;
  } else {
    datas.data = data;
  }
  return request(datas);
}
export function statistics(url, method, data) {
  let datas = {
    url: '/api/statistics' + url,
    method: method
  };
  if (method == 'get') {
    datas.params = data;
  } else {
    datas.data = data;
  }
  return request(datas);
}
// 卡管理
export function cardManage(url, method, data) {
  let datas = {
    url: '/api/card/operate' + url,
    method: method,
  };
  if (method == 'get') {
    datas.params = data;
  } else {
    datas.data = data;
  }
  return request(datas);
}
